<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>for循环演示</title>
</head>
<body>
    {% for student in students %}
        <li>{{ student.name }}</li>
        {% empty %}
            <h2>内容为空</h2>
    {% endfor %}
<hr>
    {% for stu in stus %}
        <li>{{ forloop.counter }}: {{ stu.name }}</li>
    {% endfor %}

<hr>
    {% for stu in stus %}
        <li>{{ forloop.counter0 }}: {{ stu.name }}</li>
    {% endfor %}

<hr>
    {% for stu in stus %}
        <li>{{ forloop.revcounter }}: {{ stu.name }}</li>
    {% endfor %}

<hr>
    {% for stu in stus %}
        <li>{{ forloop.revcounter0 }}: {{ stu.name }}</li>
    {% endfor %}

<hr>
    {% for stu in stus %}
        <li>{{ forloop.last }}: {{ stu.name }}</li>
    {% endfor %}

<hr>
    {% for stu in stus %}
        {% if forloop.counter|divisibleby:2 %}
        
        {% endif %}
        <li>{{ forloop.first }}: {{ stu.name }}</li>
    {% endfor %}

{% autoescape off %}

{% endautoescape %}

</body>
</html>